Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

1.15 Other Common Utilities

echo — Display a Line of Text

Format:

echo [options] [string]

Common Options:

  • -n: Suppress the trailing newline character character.

  • -e: Enable interpretation of backslash escape sequences.

  • -E: Explicitly disable interpretation of backslash escape sequences (Default behavior).

Supported Escape Sequences:

SequenceArchitectural Meaning / Action
\nNewline character.
\tHorizontal tab character.
\\Literal backslash.
\rCarriage return character.
\bBackspace control sequence.
\aAlert (system bell or beep tone).
\cProduce no further output (terminates processing).

Examples:

$ echo david

$ name="My name is David"

$ echo $name

$ echo -e "Hello \nWorld"

(Note: Evaluation of escape sequences occurs explicitly when enveloped within double quote pairs).

The Functional Distinctions Between ' ' and " ":
Within a Linux Shell architecture (such as ), single quotes (' ') and double quotes (" ") both enclose string assignments, but their low-level translation behaviors differ strictly:

Technical Feature'Single Quotes'"Double Quotes"
Variable Expansion❌ Suppressed (Literal Interpretation)✅ Executed (Expands $VAR)
Command Substitution❌ Suppressed✅ Executed (Runs `cmd` or $())
Escape Character Processing❌ Suppressed (Except \'in raw terms)✅ Partially Interpreted
Wildcard Globbing❌ Suppressed❌ Suppressed

ln — Create Link Files Utility

Format:

ln [options] target link_name

Common Options:

  • -s: Generate a symbolic / soft link instead of a hard link.

  • -f: Force remove existing destination files.

  • -i: Prompt interactively prior to removing existing destination targets.

  • -v: Verbose mode (print file names handled by the utility).

  • -n: Treat the destination link name as a normal file if it points to a directory symbolic link (prevents deep resolution).

  • -d: Permit the superuser (root) to attempt hard linking directories.

Links are split architecturally into hard links and symbolic links. A hard link shares the identical index node (inode) entry as the original target; removing one link reference leaves remaining nodes unharmed. A symbolic link (or soft link) functions as a pointer path pointing to the original filename; if the source file is deleted, the soft link stays intact but breaks, resulting in a dangling link.

Examples:

$ ln file.txt file_link.txt # Instantiates a hard link pointing to the same inode

$ ln -s file.txt soft_link.txt # Instantiates a soft symbolic reference link

export — Set Environment Variable Attributes

Format:

export [options] [variable_name[=value]]

Common Options:

  • -p: Display a listing of all currently exported system environment variables.

  • -n: Strip the export attribute from named variables, reverting them to local shell scope.

  • -f: Treat the targeted arguments as names of shell functions to export.

Examples:

$ export -p

$ export PATH=$PATH:/opt/bin

$ export JAVA_HOME=/usr/lib/jvm/java-11

env — Display or Temporarily Modify the Execution Environment

Format:

env [options] [NAME=VALUE...] [command [arguments...]]

Common Options:

  • No Arguments: Dumps a listing of all currently active environment variables to stdout.

  • VAR=val: Appends a temporary environment entry strictly for the duration of the trailing command invocation.

  • -i: Start with an empty environment, fully discarding inheritance values.

  • -u VAR: Purge variable VAR from the localized active environment tracking block.

Examples:

$ env

$ env DEBUG=1 ./program

$ env -i

$ env -u PATH
Copyright © 2026 Guangzhou eSmart Information Technology Co., Ltd. All Rights Reserved.
All content in this book is copyrighted by the author. For personal learning and exchange only. Commercial use without authorization is strictly prohibited. Email:

✉ 3348194517@qq.com | hai616878@gmail.com